package com.example.base_model.weight

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.vector.ImageVector

/**
 * @author 宾有为
 * @date 2025/8/2 10:14
 * @link https://blog.csdn.net/baidu_41616022?type=blog
 * @describe：
 **/

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun MyTopBar(
    title: String = "",
    onClickAction: () -> Unit = {},
    showAction: Boolean = true,
    image: ImageVector = Icons.Default.ArrowBack,
    description: String = "返回",
) {
    TopAppBar(title = {
        Text(text = title)
    }, navigationIcon = {
        if (showAction) {
            IconButton(onClick = { onClickAction.invoke() }) {
                Icon(image, contentDescription = description)
            }
        }
    })
}